<?php

namespace Database\Seeders;

use App\Models\Admin\SysPermission;
use App\Models\Admin\SysRole;
use App\Models\Admin\SysUser;
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;

class BatchAssignSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $role = SysRole::find(1);
        $role->menus()->sync([1,6]);
        $role = SysRole::find(1);
        $permissionIds = SysPermission::select('id')->get()->pluck('id')->flatten()->toArray();
        $role->permissions()->sync($permissionIds);
        $user = SysUser::find(1);
        $user->sysRoles()->sync([1]);

        $user = SysUser::find(2);
        $user->sysRoles()->sync([1]);
    }
}
